﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace lcmyjobs.Web.findjobs
{
    public partial class JobSearchResume : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Application["webname"] != null)
                {
                    this.Title = string.Format("职位搜索-- {1}猎头 {1}猎头公司 聊城猎头 聊城猎头公司 {0} ", Application["webname"].ToString(), Application["webregion"].ToString());
                }
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            StringBuilder url = new StringBuilder("JobSearchResult.html");
            url.Append(GetStr());

            Response.Redirect(url.ToString());
        }

        private string GetStr()
        {
            StringBuilder str = new StringBuilder("?");

            int type = 0;
            if (rbtNo.Checked) type = 0;
            if (rbtnew.Checked) type = 2;
            if (rbtold.Checked) type = 1;
            string area = txtarea.Text.Trim();
            string trade = txttrade.Text.Trim();
            int salary = int.Parse(ddlsalarym.SelectedValue.ToString());
            int edu = int.Parse(ddledu.SelectedValue.ToString());
            //int mtime = 0;
            //string mtimes = "";
            //if (rbtt0.Checked) mtime = 0;
            //if (rbtt1.Checked) mtime = 1;
            //if (rbtt2.Checked) mtime = 2;
            //if (rbtt3.Checked) { mtime = 3; mtimes = txttime.ToString(); }
            int exp = int.Parse(ddlExp.SelectedValue.ToString());
            string major = txtmajor.Text.Trim();
            int lan = int.Parse(selange.Value.ToString());
            int level = int.Parse(selevel.Value.ToString());
            //string rtime = txtrTime.Text.Trim();

            string rtime = this.ddl_rtime.SelectedItem.Value;

            if (rtime == "不限")
            {
                rtime = "0";
            }
            if (rtime == "近三天")
            {
                rtime = "1";
            }
            if (rtime == "近一周")
            {
                rtime = "2";
            }
            if (rtime == "近半月")
            {
                rtime = "3";
            }
            if (rtime == "近一月")
            {
                rtime = "4";
            }
            if (rtime == "近两月")
            {
                rtime = "5";
            }
            if (rtime == "近三月")
            {
                rtime = "6";
            }


            string jobs = txtjob.Text.Trim();
            string jobsClass = this.hid_jobclass.Value;
            string jobs_id = "";
            string key_words = this.txt_keywords.Text;

            if (!string.IsNullOrEmpty(jobs))
            {
                string[] jobsl = jobs.Split(',');
                string[] jobsClassl = jobsClass.Split(',');



                if (jobsl.Length > 0)
                {
                    for (int i = 0; i < jobsl.Length; i++)
                    {
                        DataSet ds = new lcmyjobs.BLL.jobs().GetList(" job_name = N'" + jobsl[i] + "' AND jobclassname =N'" + jobsClassl[i] + "' ");

                        jobs_id += ds.Tables[0].Rows[0]["jobs_id"].ToString() + ",";
                    }

                    jobs_id.Substring(0, jobs_id.Length - 1);
                }
            }







            str.Append("workerclass=" + type);
            str.Append("&jobsname=" + jobs_id);
            str.Append("&areaname=" + area);
            str.Append("&tradename=" + trade);
            str.Append("&salary=" + salary);
            str.Append("&edu=" + edu);
            str.Append("&exp=" + exp);
            str.Append("&majorname=" + major);
            str.Append("&lan=" + lan);
            str.Append("&level=" + level);
            str.Append("&releasetime=" + rtime);
            str.Append("&key_words=" + key_words);



            return str.ToString();
        }
    }
}